package com.example.mbl.controller;

import com.example.mbl.entity.Gallery;
import com.example.mbl.interceptor.AppToken;
import com.example.mbl.result.PageResult;
import com.example.mbl.result.WebRestResult;
import com.example.mbl.result.business.GalleryPageResult;
import com.example.mbl.service.GalleryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("Gallery")
@RestController
public class GalleryController {
    @Autowired
    private GalleryService galleryService;

    @AppToken
    @PostMapping("addGallery")
    public WebRestResult addEvent(@RequestBody Gallery gallery){
        WebRestResult result = galleryService.addGallery(gallery);
        return result;
    }

    @AppToken
    @PostMapping("deleteGallery")
    public WebRestResult deleteEvent(@RequestBody Gallery gallery){
        WebRestResult result = galleryService.deleteGallery(gallery);
        return result;
    }

    @AppToken
    @PostMapping("updateGallery")
    public WebRestResult updateEvent(@RequestBody Gallery gallery){
        WebRestResult result = galleryService.updateGallery(gallery);
        return result;
    }

    @GetMapping("getGalleryList")
    public PageResult<GalleryPageResult> getGalleryList(String date,int page,int pagesize){
        PageResult<GalleryPageResult> result = galleryService.getGalleryList(date,page,pagesize);
        return result;
    }
}
